{extend name="public/base" /}

{block name="title"}添加站点{/block}

{block name="main"}
<style>
.layui-form-label{
    padding: 9px 10px 9px 0px;
    width: 100px;
}

</style>
<div class="layui-tab" id="Js_title_navigation">
    <ul class="layui-tab-title">
        <li class="layui-this">添加站点</li>
    </ul>
</div>
<form class="layui-form layui-row " action="" method="post">
	<div class="layui-col-xs12" style="padding-bottom: 50px;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>站点基础信息</legend>
        </fieldset>
        <div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>网站名称：</label>
			<div class="layui-input-block">
				<input type="text" name="name" lay-verify="required" required value="" placeholder="请输入网站的名称" class="layui-input">
			</div>
		</div>
        <div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>联系人：</label>
			<div class="layui-input-block">
				<input type="text" name="contactname" lay-verify="required" required value="" placeholder="请输入网站联系人姓名" class="layui-input">
			</div>
		</div>
        <div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>联系信息：</label>
			<div class="layui-input-block">
				<input type="text" name="contacttel" lay-verify="required" value="" placeholder="请输入网站联系人的联系电话" class="layui-input">
			</div>
		</div>
        <!--站点配置信息-->
        <div class="layui-form-item ">
			<label class="layui-form-label">域名配置：</label>
            <div class="layui-input-block" >
                <input type="radio" name="domaintype" value="1" lay-filter="domaintype" title="独立域名"  />
                <input type="radio" name="domaintype" value="2" lay-filter="domaintype" title="个性域名" />
                <input type="radio" name="domaintype" value="3" lay-filter="domaintype" title="随机域名" checked />
            </div>
        </div>
        <div class="layui-form-item" id="JS_domain" style="display: none;">
			<label class="layui-form-label">网站域名：</label>
			<div class="layui-input-inline">
				<input type="text" name="domain" value="" placeholder="请填写网站域名" class="layui-input" />
			</div>
            <div class="layui-form-mid layui-word-aux">
                <span id="domaintype_tip_1" >独立域名：写一二级域名即可,例如百度请写<b>baidu.com</b></span>
                <span id="domaintype_tip_2" style="display: none;">个性域名: 仅字母或数字组成的字符串,将链接<b>{$domain}</b>拼成完整域名</span>
                <span id="domaintype_tip_3" style="display: none;">域名配置说明</span>
            </div>
		</div>
        
        <div class="layui-form-item ">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>站点logo：</label>
			<div class="layui-input-block">
                <input type="hidden" name="logo" value="" id="JS_logo" />
                <div class="e-upload-img" id="JS_upload_img" style="display: none;"><img src="" /></div>                    
                <button type="button" class="layui-btn" id="JS_upload_btn">
                    <i class="layui-icon">&#xe67c;</i>上传图片</button>
			</div>
		</div>
        
        <div class="layui-form-item ">
			<label class="layui-form-label">地址：</label>
			<div class="layui-input-block" id="JS_area">
	     	</div>
            <div class="layui-input-block" style="width: 400px; margin-top: 10px;">
				<input type="text" name="addressdetail" value="" placeholder="详细地址" class="layui-input">
			</div>
		</div>
        
        <fieldset class="layui-form-item layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>站点管理员信息</legend>
        </fieldset>
        
		<div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>登录账户：</label>
			<div class="layui-input-block">
				<input type="text" name="account" lay-verify="required|username" value="" placeholder="请输入管理员后台的登录账户" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>登录密码：</label>
			<div class="layui-input-block">
				<input type="password" name="password" value="" placeholder="请设置管理员密码" lay-verify="required" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">
                <span class="e-input-required" >*</span>确认密码：</label>
			<div class="layui-input-block">
				<input type="password" name="confirmpwd" value="" placeholder="请确认密码" lay-verify="required" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">真实姓名：</label>
			<div class="layui-input-block">
				<input type="text" name="truename" value="" placeholder="请输入管理员的真实姓名" class="layui-input pwd">
			</div>
		</div>
        <div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">性别：</label>
			<div class="layui-input-block">     
                <input type="radio" name="gender" value="1" title="男" checked />
                <input type="radio" name="gender" value="2" title="女" />
                <input type="radio" name="gender" value="3" title="未知"/>
			</div>
		</div>
		<div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">手机号：</label>
			<div class="layui-input-block">
				<input type="text" name="mobile" value="" placeholder="请输入管理员手机号" class="layui-input pwd">
			</div>
		</div>
        <div class="layui-form-item layui-col-md4">
			<label class="layui-form-label">邮箱：</label>
			<div class="layui-input-block">
				<input type="text" name="email" value="" placeholder="请输入管理员邮箱" class="layui-input pwd">
			</div>
		</div>
                 
	</div>
    <div class="layui-layout-admin" >
        <div class="layui-footer" style="left:0;">
            <div class="layui-form-item">
                <a href="javascript:;" class="layui-btn layui-btn-primary" onclick="javascript:history.back();">返回</a>
				<button type="button" class="layui-btn" lay-submit="" lay-filter="addFrom">立即添加</button>
			</div>
        </div>
    </div>
    

</form>
{/block}
{block name="script"}
<!--
<script type="text/javascript" src="{$htmlStaticPath}/lib/cropper/cropper.js"></script>
<link rel="stylesheet" href="{$htmlStaticPath}/lib/cropper/cropper.css" media="all" />
-->
<script>  

layui.use(['form','common','layer','uploadimg','linkSelect'],function(){
    var form = layui.form;
    var uploadimg = layui.uploadimg;
    // 域名
    form.on('radio(domaintype)', function(data){
        if( data.value == 3 ){
            $('#JS_domain').hide();
        }else{
            $('#JS_domain').show();
            $('#JS_domain span').hide();
            $('#domaintype_tip_'+data.value).show();
        }
    });  
    // 省市区选择
    var linkConfig = {
        defname : ['请选择','请选择','请选择','请选择'],
        url     : '/sys/area/getlist',// '/syscode/ajaxcodelist',    联动请求网址getlist
        urlpid  : 'pcode',           // 请求下一级时 的服务器接收父级ID参数名称
        depth   : 4,            // 限制请求的展示的级别
        fname   : 'name',   // 原数据需要展示的字段名称
        fval    : 'code',   // 原数据需要提交的字段名称
        id      : $('#JS_area'),   // 联动HTML 存放的div容器对象
        fromname: 'code',       // 提交表单的字段名称
    }
    layui.linkSelect.setConfig(linkConfig);
    
    // 上传图片
    uploadimg.render({
        saveH : 300,
        saveW : 300,
        elem : '#JS_upload_btn',
        url  : '/sys/Upload/image', //上传接口
        type : 'logo',
        done : function(ret){
            if( ret.code == 1 ){
                $('#JS_upload_img').show();
                $('#JS_upload_img img').attr('src',ret.data);
                $('#JS_logo').val(ret.data);
            }else{
                layui.common.tip(ret.msg);
            }
        }
    });    
    
    form.on('submit(addFrom)',function(data){
        if(data.field.password.length<6){
            layer.msg("密码长度不能小于6",{icon:5});
            return false;
        }
        if(data.field.password!=data.field.confirmpwd){
            layer.msg("两次输入密码不一致",{icon: 5});
            return false;
        }
        layui.common.post("/site/site/add",data.field);
        return false;
    });
    
    form.render(); //更新全部
});
</script>
{/block}